﻿using System;
using System.Data;

namespace ExtAspNet.Examples.grid
{
    public partial class grid_checkboxfield : PageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindGrid();
            }
        }

        #region BindGrid

        private void BindGrid()
        {
            DataTable table = GetDataTable();

            Grid1.DataSource = table;
            Grid1.DataBind();

        }

        #endregion


        #region Events


        protected void Grid1_RowCommand(object sender, ExtAspNet.GridCommandEventArgs e)
        {
            if (e.CommandName == "CheckBox1")
            {
                bool checkState = Convert.ToBoolean(Grid1.Rows[e.RowIndex].States[e.ColumnIndex]);
                Alert.ShowInTop(String.Format("你点击了第 {0} 行，第 {1} 列，选中状态：{2}", e.RowIndex, e.ColumnIndex, checkState));
            }
            else if (e.CommandName == "Action1" || e.CommandName == "Action2")
            {
                Alert.ShowInTop(String.Format("你点击了第 {0} 行，第 {1} 列，行命令是 {2}", e.RowIndex, e.ColumnIndex, e.CommandName));
            }
        }

        #endregion


    }
}
